<template>
  <div class="box p15">
    <div class="dept-add p15">
      <h3>创建公司</h3>
      <el-form ref="form" :model="form" label-width="120px" v-loading="loading">
        <el-form-item label="公司名称" class="no-border">
          <el-input v-model="form.folderName" />
        </el-form-item>
        <el-form-item label="纳税类型">
          <el-select v-model="form.payTaxesType" placeholder="请选择">
            <el-option v-for="t in typeOptions" :key="t.id" :label="t.title" :value="t.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="主营业务" class="no-border">
          <el-input v-model="form.business" />
        </el-form-item>
        <el-form-item label="人员规模">
          <el-select v-model="form.scale" placeholder="请选择">
            <el-option v-for="t in scaleOptions" :key="t.id" :label="t.title" :value="t.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="初始账期">
          <el-date-picker
            v-model="form.startDate"
            type="date"
            placeholder="选择日期"
            style="width: 100%;"
            value-format="yyyy-MM-dd"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submit">提交</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import { save } from '@/api/company'
export default {
  data() {
    return {
      loading: false,
      form: {
        folderName: '',
        type: '',
        business: '',
        scale: '',
        startDate: '',
        moneyType: '1',
        name: ''
      },
      typeOptions: [
        { id: '1', title: '小规模纳税人' },
        { id: '2', title: '一般纳税人' }
      ],
      scaleOptions: [
        { id: '1', title: '0-20人' },
        { id: '2', title: '20-99人' },
        { id: '3', title: '100-499人' },
        { id: '4', title: '500-999人' },
        { id: '5', title: '1000-9999人' },
        { id: '6', title: '10000人以上' }
      ]
    }
  },
  methods: {
    submit() {
      this.loading = true
      save(this.form).then(res => {
        this.loading = false
        this.$message.success(res.message)
        this.$store.dispatch('user/getInfo')
        this.$router.push({ path: '/' })
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.dept-add {
  width: 500px;
  background: #fff;
  margin: 0 auto;
  h3 {
    text-align: center;
  }
}
</style>
